<template>
  <div class="message-template">
    <p>
      您收到一条新的
      <em>{{ noticeMap[message.itemType].type }}</em>
      消息
    </p>
    <span @click="messageArchive">前往查看</span>
  </div>
</template>

<script>
import { noticeMap } from '~/config/optionMap'
export default {
  props: {
    message: {
      type: Object,
      default: () => {}
    },
    instance: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      noticeMap
    }
  },

  methods: {
    messageArchive () {
      const route = this.noticeMap[this.message.itemType].to
      this.$nuxt.$router.push(route)
      this.$notification.close(this.instance)
    }
  }
}
</script>

<style lang="less" scoped>
.message-template {
  padding: 12px 0 20px;
  p {
    font-size: 12px;
    em {
      color: var(--primary-color);
      font-style: normal;
      margin: 0 2px;
    }
  }
  span {
    color: var(--primary-color);
    cursor: pointer;
    margin-top: 10px;
    float: right;
    letter-spacing: 1px;
    font-size: 12px;
  }
}
</style>
